﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RakutenCrawler.Repository
{
    public class ManufacturerRepository : GenericRepository<Manufacturer>
    {
        public override void InsertOrUpdate(Manufacturer item)
        {
            var check = Single(m => m.ManufacturerName == item.ManufacturerName || m.ManufacturerId == item.ManufacturerId);
            if (check == null)
            {
                item.InsertedDate = DateTime.Now;
                All.AddObject(item);
            }
            else
            {

                item.ManufacturerId = check.ManufacturerId;
                item.InsertedDate = check.InsertedDate;
                All.ApplyCurrentValues(item);
            }
        }
    }
}
